﻿using System.Threading;

namespace IInject
{
	public class ContainerProvider
	{
		private static volatile IContainer _container;

		private ContainerProvider()
		{
		}

		///<summary>
		/// The current <see cref="IContainer"/>.
		///</summary>
		public static IContainer Current
		{
			get
			{
				return _container;
			}
		}

		///<summary>
		/// Sets the current <see cref="IContainer"/>.
		///</summary>
		///<param name="container">The <see cref="IContainer"/> to use.</param>
		public static void SetCurrent(IContainer container)
		{
			if (container != null)
			{
				Interlocked.Exchange(ref _container, container);
			}
		}
	}
}
